package com.yxb.evaluation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxb.common.annotation.Log;
import com.yxb.common.core.controller.BaseController;
import com.yxb.common.core.domain.AjaxResult;
import com.yxb.common.enums.BusinessType;
import com.yxb.evaluation.domain.Evaluation;
import com.yxb.evaluation.service.IEvaluationService;
import com.yxb.common.utils.poi.ExcelUtil;
import com.yxb.common.core.page.TableDataInfo;

/**
 * 双向评价记录Controller
 * 
 * @author 林德炫
 * @date 2025-03-04
 */
@RestController
@RequestMapping("/evaluation/evaluation")
public class EvaluationController extends BaseController
{
    @Autowired
    private IEvaluationService evaluationService;

    /**
     * 查询双向评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Evaluation evaluation)
    {
        startPage();
        List<Evaluation> list = evaluationService.selectEvaluationList(evaluation);
        return getDataTable(list);
    }

    /**
     * 导出双向评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:export')")
    @Log(title = "双向评价记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Evaluation evaluation)
    {
        List<Evaluation> list = evaluationService.selectEvaluationList(evaluation);
        ExcelUtil<Evaluation> util = new ExcelUtil<Evaluation>(Evaluation.class);
        util.exportExcel(response, list, "双向评价记录数据");
    }

    /**
     * 获取双向评价记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:query')")
    @GetMapping(value = "/{evalId}")
    public AjaxResult getInfo(@PathVariable("evalId") Long evalId)
    {
        return success(evaluationService.selectEvaluationByEvalId(evalId));
    }

    /**
     * 新增双向评价记录
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:add')")
    @Log(title = "双向评价记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Evaluation evaluation)
    {
        return toAjax(evaluationService.insertEvaluation(evaluation));
    }

    /**
     * 修改双向评价记录
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:edit')")
    @Log(title = "双向评价记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Evaluation evaluation)
    {
        return toAjax(evaluationService.updateEvaluation(evaluation));
    }

    /**
     * 删除双向评价记录
     */
    @PreAuthorize("@ss.hasPermi('evaluation:evaluation:remove')")
    @Log(title = "双向评价记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evalIds}")
    public AjaxResult remove(@PathVariable Long[] evalIds)
    {
        return toAjax(evaluationService.deleteEvaluationByEvalIds(evalIds));
    }
}
